(function() {
    require.config({
        baseUrl: '/app/',
        paths: {
            'es5-shim': 'lib/es5-shim/es5-shim.min',
            'es6-shim': 'lib/es6-shim/es6-shim.min',
            'babel-polyfill': 'lib/es6-shim/browser-polyfill.min',
            'rcss': 'lib/require-css/css',
            'css-builder': 'lib/require-css/css-builder',
            'normalize': 'lib/require-css/normalize',
            'rtext': 'lib/require-text/text',
            'base64': 'lib/es6-shim/base64',
            'underscore': 'lib/underscore.js/underscore',
            'json2': 'lib/json/json2',
            'json5': 'lib/json/json5.min',
            'mock': 'lib/mock.js/mock',
            'jquery': 'lib/jquery/jquery.min',
            'jquery-ui': 'lib/jquery/jquery-ui.min',
            'jquery.form': 'lib/jquery/jquery.form',
            'jquery.format': 'lib/jquery/jquery.format',
            'clipboard': 'lib/clipboard.js/clipboard.min',
            'bootstrap': 'lib/bootstrap/js/bootstrap.min',
            'metisMenu': 'lib/metisMenu/metisMenu.min',
            'angular': 'lib/angular.js/angular.min',
            'angularAMD': 'lib/angular.amd/angularAMD',
            'angular-route': 'lib/angular.js/angular-route.min',
            'angular-animate': 'lib/angular.js/angular-animate.min',
            'angular-sanitize': 'lib/angular.js/angular-sanitize.min',
            'angular-cookies': 'lib/angular.js/angular-cookies.min',
            'angular-toastr': 'lib/angular-toastr/angular-toastr.min',
            'angular-toastr.tpls': 'lib/angular-toastr/angular-toastr.tpls.min',
            'angular-loading-bar': 'lib/angular-loading-bar/loading-bar.min',
            'angular-ui-select': 'lib/angular-ui-select/select.min',
            'angular-ui-bootstrap': 'lib/angular-ui-bootstrap/ui-bootstrap-tpls.min',
            'ng-file-upload': 'lib/ng-file-upload/ng-file-upload.min',
            'ng-file-upload-shim': 'lib/ng-file-upload/ng-file-upload-shim.min',
            'showdown': 'lib/ng-showdown/showdown',
            'ng-showdown': 'lib/ng-showdown/ng-showdown.min',
            'highlight': 'lib/highlight.js/highlight.pack',
            'standalone': 'lib/prettier/standalone',
            'parser-babylon': 'lib/prettier/parser-babylon',
            'parser-yaml': 'lib/prettier/parser-yaml',
            'parser-postcss': 'lib/prettier/parser-postcss',
            'parser-html': 'lib/prettier/parser-html',
            'parser-typescript': 'lib/prettier/parser-typescript',
            'mathjax': 'lib/mathjax3/mj3-tex2svg-global.dist',
            'flowchart': 'lib/flowchart.js/flowchart.min',
            'Raphael': 'lib/flowchart.js/raphael.min',
            'html2canvas': 'lib/html-canvas/html2canvas.min',
            'canvas2image': 'lib/html-canvas/canvas2image',
            'jspdf': 'lib/html-canvas/jspdf.debug',
            'fuzzysearch': 'lib/zTree.v3/js/fuzzysearch',
            'zTree': 'lib/zTree.v3/js/jquery.ztree.all.min',
            'zTree-exhide': 'lib/zTree.v3/js/jquery.ztree.exhide.min',
            'ace': 'lib/ace/ace',
            'ace-language-tools': 'lib/ace/ext-language_tools',
            'ace-diff': 'lib/ace-diff/ace-diff.min',
            'sql-formatter': 'lib/sql-formatter/sql-formatter.min',
            'moment': 'lib/moment.js/moment-with-locales',
            'moment-timezone': 'lib/moment.js/moment-timezone-with-data',
            'bootstrap-datetimepicker': 'lib/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min',
            'csv': 'lib/handsontable/csv.min',
            'handsontable': 'lib/handsontable/handsontable.full.min',
            'handsontable-zh-CN': 'lib/handsontable/languages/zh-CN.min'
        },
        shim: {
            'es6-shim': ['es5-shim', 'babel-polyfill'],
            'underscore': { exports: '_' },
            'jquery-ui': ['jquery'],
            'jquery.form': ['jquery'],
            'jquery.format': ['jquery'],
            'bootstrap': ['jquery-ui', 'rcss!lib/bootstrap/css/bootstrap.min', 'rcss!lib/font-awesome/css/font-awesome.min'],
            'metisMenu': ['bootstrap', 'rcss!lib/metisMenu/metisMenu.min', 'rcss!lib/metisMenu/css/mm-vertical2'],
            'angular': { deps: ['jquery'], exports: 'angular' },
            'angularAMD': ['angular'],
            'angular-route': ['angular'],
            'angular-animate': ['angular'],
            'angular-sanitize': ['angular'],
            'angular-cookies': ['angular'],
            'angular-toastr': ['angular-animate', 'rcss!lib/angular-toastr/angular-toastr.min'],
            'angular-toastr.tpls': ['angular-toastr'],
            'angular-loading-bar': ['angular-animate', 'rcss!lib/angular-loading-bar/loading-bar.min'],
            'angular-ui-select': ['angular', 'rcss!lib/angular-ui-select/select.min'],
            'angular-ui-bootstrap': ['angular', 'bootstrap'],
            'ng-file-upload': ['angular'],
            'ng-file-upload-shim': ['ng-file-upload'],
            'ng-showdown': ['showdown', 'angular-sanitize'],
            'highlight': { deps: ['jquery', 'rcss!lib/highlight.js/styles/googlecode'], exports: 'hljs' },
            'mathjax': { exports: 'MathJax' },
            'flowchart': ['jquery', 'Raphael'],
            'jspdf': { deps: ['jquery', 'html2canvas'], exports: 'jsPDF' },
            'fuzzysearch': ['jquery'],
            'zTree': ['jquery', 'rcss!lib/zTree.v3/css/metroStyle/metroStyle'],
            'zTree-exhide': ['zTree'],
            'ace-language-tools': ['ace'],
            'ace-diff': ['rcss!lib/ace-diff/ace-diff.min'],
            'moment-timezone': ['moment'],
            'bootstrap-datetimepicker': ['bootstrap', 'moment', 'rcss!lib/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min'],
            'handsontable': ['bootstrap', 'rcss!lib/handsontable/handsontable.full.min'],
            'handsontable-zh-CN': ['handsontable'],
            'app': ['es6-shim', 'underscore', 'angular', 'bootstrap']
        },
        deps: ['build'],
        callback: function(args) {
            require(['ace'], function() {
                ace.config.set('basePath', '/app/lib/ace');
            });
            setTimeout(function() {
                $('.x-loading').fadeOut().remove();
            }, 500);
        },
        waitSeconds: 60
    });
})();
